<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('库存调拨回传列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>移动类型：</label>
                            <input type="text" name="BWART"/>
                        </li>
                        <li>
                            <label>行项目编号：</label>
                            <input type="text" name="ZEILE"/>
                        </li>
                        <li>
                            <label>工厂：</label>
                            <input type="text" name="WERKS"/>
                        </li>
                        <li>
                            <label>物料号：</label>
                            <input type="text" name="MATNR"/>
                        </li>
                        <li>
                            <label>源库存地点：</label>
                            <input type="text" name="LGORT"/>
                        </li>

                        <li>
                            <label>批号：</label>
                            <input type="text" name="CHARG"/>
                        </li>
                        <li>
                            <label>工单：</label>
                            <input type="text" name="AUFNR"/>
                        </li>
                        <li>
                            <label>源销售订单号：</label>
                            <input type="text" name="KDAUF"/>
                        </li>
                        <li>
                            <label>源销售订单行号：</label>
                            <input type="text" name="KDPOS"/>
                        </li>
                        <li>
                            <label>序列号：</label>
                            <input type="text" name="SERNR"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="sap:StockTransfer:add">-->
            <!--<i class="fa fa-plus"></i> 添加-->
            <!--</a>-->
            <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="sap:StockTransfer:edit">-->
            <!--<i class="fa fa-edit"></i> 修改-->
            <!--</a>-->
            <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="sap:StockTransfer:remove">-->
            <!--<i class="fa fa-remove"></i> 删除-->
            <!--</a>-->
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="sap:StockTransfer:export">-->
            <!--<i class="fa fa-download"></i> 导出-->
            <!--</a>-->
            <a class="btn btn-primary multiple disabled" onclick="reloadType()">
            <i class="fa fa-edit"></i>&nbsp;重新过账</a>
            <a class="btn btn-primary multiple disabled" onclick="callType()">
                <i class="fa fa-edit"></i>&nbsp;过账</a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('sap:StockTransfer:edit')}]];
    var removeFlag = [[${@permission.hasPermi('sap:StockTransfer:remove')}]];
    var prefix = ctx + "sap/StockTransfer";
    var statusDatas = [[${@dict.getType('transfer_status')}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            reloadTypeUrl: prefix + "/reloadType",
            callTypeUrl: "/API/SAP/ZFL_WMS_STOCK_TRANSFER",
            uniqueId:"tranGuid",
            modalName: "库存调拨回传",
            columns: [{
                checkbox: true
            },
                {
                    field: 'budat',
                    title: '过帐日期'
                },
                {
                    field: 'refDocNo',
                    title: '参考凭证编号'
                },
                {
                    field: 'headerTxt',
                    title: '凭证抬头文本'
                },
                {
                    field: 'bwart',
                    title: '物料移动类型'
                },
                {
                    field: 'evType',
                    title: '返回消息类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'evMessage',
                    title: '返回消息'
                },
                {
                    field: 'zeile',
                    title: '行项目编号'
                },
                {
                    field: 'werks',
                    title: '工厂'
                },
                {
                    field: 'werksTo',
                    title: '目标工厂'
                },
                {
                    field: 'matnr',
                    title: '物料号'
                },
                {
                    field: 'matnrTo',
                    title: '目标物料号'
                },
                {
                    field: 'lgort',
                    title: '源库存地点'
                },
                {
                    field: 'lgortTo',
                    title: '目标库存地点'
                },
                {
                    field: 'erfmg',
                    title: '以输入单位计的数量'
                },
                {
                    field: 'erfme',
                    title: '条目单位'
                },
                {
                    field: 'charg',
                    title: '批号'
                },
                {
                    field: 'chargTo',
                    title: '目标批号'
                },
                {
                    field: 'aufnr',
                    title: '工单'
                },
                {
                    field: 'rsnum',
                    title: '预留'
                },
                {
                    field: 'rspos',
                    title: '预留行号'
                },
                {
                    field: 'kdauf',
                    title: '源销售订单号'
                },
                {
                    field: 'kdpos',
                    title: '源销售订单行号'
                },
                {
                    field: 'matKdauf',
                    title: '目标销售订单号'
                },
                {
                    field: 'matKdpos',
                    title: '目标销售订单行号'
                },
                {
                    field: 'tranGuid',
                    title: '主键标识'
                },
                {
                    field: 'sernr',
                    title: '序列号'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ZEILE + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ZEILE + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function reloadType() {
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录！");
            return;
        }
        if (rows.length > 1) {
            $.modal.alertWarning("只允许选择一条记录！");
            return;
        }

        $.modal.confirm("确认要重新下发选中的" + rows.length + "条任务吗?", function () {
            var url = table.options.reloadTypeUrl;
            var data = {"tranGuid": rows.join()};
            $.operate.submit(url, "post", "json", data);
        });
    }

    function callType() {
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录！");
            return;
        }
        if (rows.length > 1) {
            $.modal.alertWarning("只允许选择一条记录！");
            return;
        }

        $.modal.confirm("确认要重新下发选中的" + rows.length + "条任务吗?", function () {
            var url = table.options.callTypeUrl;
            var data = {"tranGuid": rows.join(),"tran_guid": rows.join()};
            $.operate.submit(url, "post", "json", data);
        });
    }

</script>
</body>
</html>